public class test{
	public static void main(String[] args)
	{
		boolean [] st = new boolean [200000];
		int [] prime = new int [200000];
		int pos = 0;
		for(int i = 2; i <= 20000; i++)
		{
			if(st[i] == false) prime[++pos] = i;
			for(int j = 1; j <= pos; j++)
			{
				if(i * prime[j] > 20000) break;
				st[i * prime[j]] = true;
				if(i % prime[j] == 0) break;
			}
		}
		for(int i = 1; i <= pos; i++)
		{
			System.out.print(prime[i] + " ");
			if(i % 5 == 0) System.out.println();
		}
	}
}

